package sr.myserver.exception;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import sr.myserver.commons.Result;
import sr.myserver.vo.common.Basic;

/**
 * 函数未知错误结果流程时使用。
 *
 * @author sirui
 */
@Getter
@Slf4j
public class RunException extends RuntimeException {
    Basic.Response vm;

    public RunException() {
        super();
    }

    public RunException(Basic.Response vm) {
        super(vm.getMsg());
        this.vm = vm;
        log.error("系统处理失败，错误代码： " + vm.getCode() + ",错误消息：" + vm.getMsg());
    }

    public RunException(String code, String msg) {
        super(code);
        this.vm = Result.fail(code, msg);
        log.error("系统处理失败，错误代码： " + vm.getCode() + ",错误消息：" + vm.getMsg());
    }

    public RunException(String msg) {
        super(msg);
        this.vm = Result.fail(msg);
        log.error("系统处理失败，错误代码： " + vm.getCode() + ",错误消息：" + vm.getMsg());
    }

    public RunException(Exception e) {
        super(e);
        log.error("系统处理失败，错误代码： " + vm.getCode() + ",错误消息：" + vm.getMsg());
    }
}
